<html>
<head>
    <#assign basePath=request.contextPath>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>后台管理系统</title>
    <#include "/WEB-INF/views/template/bootMainJs.ftl" parse=true encoding="utf-8">
    <!-- bootstrap-datetimepicker -->
    <link href="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <link href="${basePath}/bootstrap/css/form.lzy.css" rel="stylesheet">
</head>
<body>
    <input id="p_update"  value="1" type="hidden">
    <input id="p_delete"  value="1" type="hidden">
    <input id="p_detail"  value="1" type="hidden">

<div class="content-header">
    <h5>平台 &gt; 基础数据管理 &gt; <strong>身份列表</strong></h5>
</div>

<div class="panel panel-lzy">
    <div class="panel-body">
        <h5 class="tips-lzy">操作提示</h5>
        <ul class="tips-list-lzy">
            <li><span>◆&nbsp;</span>该页面展示了身份管理中心所有的身份信息，可对身份进行编辑修改操作。</li>
            <li><span>◆&nbsp;</span>可输入关键字或选择项进行相关搜索（可单项搜索）。</li>
        </ul>
    </div>
</div>

<div class="panel panel-f5">
    <div class="panel-body row" style="float: right">
        <form id="myForm" class="form-inline form-margin-right">
            <div class="form-group">
                <span>身份名称：</span>
                <input type="text" placeholder="" class="form-control" id="name">
            </div>
            <%--<div class="form-group">--%>
            <%--<span>身份身份：</span>--%>
            <%--<select class="form-control required" id="identityId">--%>
            <%--<option value="" >选择身份</option>--%>
            <%--<c:forEach items="${identityList}" var="var">--%>
            <%--<option value="${var.id}" >${var.name}</option>--%>
            <%--</c:forEach>--%>
            <%--</select>--%>
            <%--</div>--%>
            <div class="form-group">
                <button type="button" class="btn btn-primary btn-sm" onclick="search(1)">查询</button>
                <button type="button" class="btn btn-primary btn-sm" onclick="$('#myForm')[0].reset();">重置</button>
            </div>
        </form>
    </div>

    <div class="panel-heading row">
        <button type="button" class="btn btn-primary" onclick="addIdentity();"><span class="fa fa-plus"></span> 新增</button>
    </div>
    <!-- 分页查询的地址-->
    <div class="panel-body panel-white">
        <div class="table-responsive">
            <table id="myTable"
                   class="table table-hover"
                   data-url="${basePath}/admin/identity/json"
                   data-pageSize="10,50,100" data-method="GET">
                <thead>
                <!-- 需要循环的字段  对应mapper文件-->
                <tr>
                    <th  data-type="checkbox" data-field="id"></th>
                    <th data-type="xuhao" >序号</th>
                    <th data-field="name">身份名称</th>
                    <th data-field="managerName">管理者</th>
                    <th data-field="incomeName">收益边界</th>
                    <th data-field="statusName">是否启用</th>
                    <th data-field="button" data-call="true">操作</th>
                </tr>
                </thead>
                <tbody id="tbodyId">
                </tbody>
            </table>
        </div>
        <!-- 分页条-->
        <div class="row">
            <div align="left" class="col-xs-6">
                <div class="input-group">
                    <span class="input-group-addon" id="pageCount"></span> <select
                        id="pageSize" onchange="search(1)" class="form-control"
                        style="width: 100px"></select>
                </div>
            </div>
            <div align="right" class="col-xs-6">
                <ul class="pagination" id="pagination"></ul>
            </div>
        </div>
    </div>
</div>

<#include "/WEB-INF/views/template/bootMainJs.ftl" parse=true encoding="utf-8">
<script type="text/javascript" src="${basePath}/bootstrap/js/utils.js" type="text/javascript"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/jqPaginator/jqPaginator.js"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/jqPaginator/myPage.js"></script>
<!-- bootstrap-datetimepicker -->
<script type="text/javascript" src="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">

    $(function () {
        $('#start_visit_time').datetimepicker({
            minView: "month", //选择日期后，不会再跳转去选择时分秒
            format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
            language: 'zh-CN', //汉化
            autoclose:true //选择日期后自动关闭
        });
        $('#end_visit_time').datetimepicker({
            minView: "month", //选择日期后，不会再跳转去选择时分秒
            format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
            language: 'zh-CN', //汉化
            autoclose:true //选择日期后自动关闭
        });
    });

    //循环列表数据以及操作按钮
    function tableCallBack(data, id){
        if(id == 'logoUrl'){
            if (data[id] != '') {
                return '<img width="50" height="50" src='+data.logoUrl+' />';
            } else if (data[id] == ''){
                return '暂无';
            }
        }
        else if(id == 'button') {//增加操作按钮
            var _button = '';
            var count = 0;
            if ($('#p_detail').val() == 1) {
                _button += '<button type="button" class="btn btn-white btn-xs" onclick="identityDetail(' + data.id + ');">查看 </button> ';
                count ++
            }
            if ($('#p_update').val() == 1) {
                _button += '<button type="button" class="btn btn-white btn-xs" onclick="editIdentity(' + data.id + ');">编辑 </button> ';
                count ++
            }
            if ($('#p_delete').val() == 1) {
                _button += '<button type="button" class="btn btn-white btn-xs" onclick="deleteIdentity(\'' + data.id + '\');">删除</button> ';
                count ++
            }

            return _button;
        } else {
            if(data[id] == null || data[id] == ''){
                return '';
            }else{
                return data[id];
            }
        }
    }

    //详情
    function identityDetail(id){
        layer.open({
            type: 2,
            area: ['70%', '80%'],
            title: '修改身份',
            content: ['${basePath}/admin/identity/detail/' + id,'yes  '],
            end:function(){
                layer.closeAll('dialog');
            }
        });
    }

    //新增
    function addIdentity(){
        layer.open({
            type: 2,
            area: ['80%', '90%'],
            title: ['新增身份','text-align:center;'],
            content: ['${basePath}/admin/identity/create','yes'],
            end:function(){
                window.location.reload();
            }
        });
    }

    //编辑
    function editIdentity(id){
        layer.open({
            type: 2,
            area: ['80%', '90%'],
            title: '修改身份',
            content: ['${basePath}/admin/identity/edit/' + id,'yes  '],
            end:function(){
                layer.closeAll('dialog');
                search(parseInt($('.active').attr('jp-data')));
            }
        });
    }

    //删除
    function deleteIdentity(id){
        layer.confirm('是否确定此操作？', {
            btn: ['确定','取消'] //按钮
        }, function() {
            $.ajax({
                type: 'POST',
                url: '${basePath}/admin/identity/delete/' + id,
                dataType: 'json',
                success: function (data) {
                    if (data.code == '0000' || data.code == '0') {
                        layer.alert('删除成功!', {
                            icon: 6
                        }, function(index){
                            layer.closeAll('dialog');
                            search(parseInt($('.active').attr('jp-data')));
                        });
                    } else {
                        layer.alert(data.desc, {
                            icon: 56
                        });
                    }
                }
            });
        });
    }


</script>
</body>
</html>